<?php 
class Application_Model_Hoa extends Zend_Db_Table
{
	protected $_name='hoa';
	
	public function getHoa($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row) {
			throw new Exception("Khong tim thay hoa $id");
		}
		return $row->toArray();
	}//phuong thuc tra ve mot dong theo $id
	
	public function addHoa($tenhoa,$dongia)
	{
		$data = array(
				'tenhoa' => $tenhoa,
				'dongia' => $dongia,
		);
		$this->insert($data);
	}//insert
	
	public function updateHoa($id, $tenhoa,$dongia)
	{
		$data = array(
				'tenhoa' => $tenhoa,
				'dongia' =>$dongia,
		);
		$this->update($data, 'id = '. (int)$id);
	}//update
	
	public function deleteHoa($id)
	{
		$this->delete('id =' . (int)$id);
	}//drop
}
?> 